package addon.w3.mdx.com;

import java.io.IOException;
import java.util.Vector;

import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
BONE						// [Bone]
	long	nbytes;
	struct {
		OBJ
		long 	GeosetID;
		long 	GeosetAnimID;
	} bones[nbons];
 * @author madjk
 *
 */
public class MDXBones extends MDXParentCOM {
	int length = -1;
	public Vector bones = null;
	
	public String getTag() {
		return "BONE";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		int cntLength = 0;
		bones = new Vector();
		
		while(cntLength < length) {
			MDXBoneCOM mdcom = new MDXBoneCOM();
			mdcom.decode(ins);
			bones.add(mdcom);
			cntLength = mdcom.obj.nbytesi+cntLength+8;
			//System.out.println(" cntLength : "+cntLength);
			//debug( mdcom.toString() );
		}
		//debug( geosets.get( (geosets.size()-1) ).toString() );
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tELEN : "+length);
		if(bones != null && bones.size() > 0) sb.append("\n\tBONES : "+bones.size());
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}